package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmQueueDao;
import com.jy.modules.cims.data.common.dto.TCMmQueueDTO;
import com.jy.platform.core.common.BaseDTO;

/**
 * @classname: TCMmQueueService
 * @description: 定义  队列表 实现类
 * @author:  dell
 */
@Service("com.jy.modules.cims.component.common.service.TCMmQueueService")
public class TCMmQueueService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmQueueDao dao;

	/**
     * @author dell
     * @description: 分页查询 队列表列表
     * @date 2017-01-19 13:47:57
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmQueueDTO> searchTCMmQueueByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmQueueDTO> dataList =  dao.searchTCMmQueueByPaging(searchParams);
		return dataList;
	}
	/**
     * @author dell
     * @description: 按条件查询队列表列表
     * @date 2017-01-19 13:47:57
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmQueueDTO> searchTCMmQueue(Map<String,Object> searchParams) throws Exception {
	    List<TCMmQueueDTO> dataList = dao.searchTCMmQueue(searchParams);
        return dataList;
    }
	/**
     * @author dell
     * @description: 查询队列表对象
     * @date 2017-01-19 13:47:57
     * @param id
     * @return
     * @throws
     */ 
	public TCMmQueueDTO queryTCMmQueueByPrimaryKey(String id) throws Exception {
		
		TCMmQueueDTO dto = dao.findTCMmQueueByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmQueueDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmQueue
     * @author dell
     * @description: 新增 队列表对象
     * @date 2017-01-19 13:47:57
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public String insertTCMmQueue(TCMmQueueDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmQueue(paramMap);
		
		TCMmQueueDTO resultDto = (TCMmQueueDTO) paramMap.get("dto");
		String keyId = resultDto.getQueueCode();
		return keyId;
	}
	/**
     * @title: updateTCMmQueue
     * @author dell
     * @description: 修改 队列表对象
     * @date 2017-01-19 13:47:57
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmQueue(TCMmQueueDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmQueue(paramMap);
	}
	/**
     * @title: deleteTCMmQueueByQueueCode
     * @author dell
     * @description: 删除 队列表,按主键
     * @date 2017-01-19 13:47:57
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmQueueByQueueCode(BaseDTO baseDto,String queueCodes) throws Exception {
		if(StringUtils.isEmpty(queueCodes)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("queueCodes", queueCodes);
		dao.deleteTCMmQueueByQueueCode(paramMap);
	}

}

